#![allow(dead_code)]

struct FnLrn {}

impl FnLrn {
    pub fn hello() {
        println!("Fn learning!");
    }
}

#[cfg(test)]
mod tests {

    #[test]
    /// 不可变借用
    fn test_fn() {
        let square = |x| x * x;
        assert_eq!(square(5), 25);
    }

    #[test]
    fn test_call_with_one() {
        fn call_with_one<F>(func: F) -> usize
        where
            F: Fn(usize) -> usize,
        {
            func(1)
        }

        let double = |x| x * 2;
        assert_eq!(call_with_one(double), 2);
    }
}
